<template>
    <div>
        <check-process
            v-bind="$attrs"
            :detail="detail"
            :disabled="disabled"
            :hasAuth="hasAuth"
            :stepStatus="stepStatus"
            :historyList="historyList"
            ref="checkPrecessRef"
            v-if="+detail.status < 3"
        >
            <template #processHistoryRecord>
                <version-record v-if="+detail.status > 1 && !detail.replenishRecord" :detail="detail" :list="historyList" />
            </template>
            <!-- <template #testHistoryRecord v-if="detail.pmpTestInformationDTO">
                <test-record :detail="detail" />
            </template> -->
        </check-process>
        <!-- 上线 -->
        <div v-else-if="+detail.status === 3">
            <h-section title="研发流程信息" collapse>
                <version-record :detail="detail" :list="historyList" />
            </h-section>
            <h-section title="测试流程" collapse v-if="detail.pmpTestInformationDTO">
                <a-form layout="inline">
                    <a-row>
                        <a-col :span="16">
                            <a-form-item label="提测需求名称" :span="24">
                                <span>{{ detail.versionName }}</span>
                            </a-form-item>
                            <a-form-item label="测试系统" :span="24">
                                <span>{{ detail.pmpTestInformationDTO.testSystem }}</span>
                            </a-form-item>
                            <a-form-item label="测试时间" :span="24">
                                <span>{{ detail.pmpTestInformationDTO.testStartTime }}</span>
                            </a-form-item>
                            <a-form-item label="测试方式" :span="24">
                                <span>自动提测</span>
                            </a-form-item>
                            <a-form-item label="测试类型" :span="24">
                                <span>{{ detail.pmpTestInformationDTO.testType }}</span>
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-form>
                <!-- <test-record :detail="detail" /> -->
            </h-section>
        </div>
        <div v-else>
            <version-record :detail="detail" :list="historyList" />
        </div>
    </div>
</template>

<script lang="ts">
import CheckProcess from '@/views/version/versionDetail/components/RelateProcess/CheckProcess/index.vue';
import VersionRecord from '@/views/version/versionDetail/components/RelateProcess/HistoryRecord/index.vue';
// import TestRecord from '@/views/version/versionDetail/components/RelateProcess/HistoryRecord/testHistoryRecord.vue';
import store from '@/store';
import { defineComponent, ref, unref, computed } from 'vue';
export default defineComponent({
    components: {
        CheckProcess,
        VersionRecord
        // TestRecord,
    },
    props: {
        detail: {
            type: Object,
            default: () => ({})
        },
        historyList: {
            type: Array,
            default: () => []
        },
        hasAuth: {
            type: Boolean,
            default: false
        },
        stepStatus: {
            type: String,
            default: ''
        }
    },
    setup(props) {
        const checkPrecessRef = ref<any>();
        const form = computed(() => {
            return unref(checkPrecessRef).form;
        });
        // 是否显示流程模块
        const disabled = computed(() => {
            // 已发布的或者是挂起等节点不显示
            if (+props.detail.status >= 3 || props.detail.jiraId) {
                return true;
            } else {
                if (props.historyList.length) {
                    // 是否自动提测
                    if (props.detail.pmpTestInformationDTO) {
                        // 需求测试和测试经理审核无需判断
                        if (props.detail.processStatus === '6') {
                            return false;
                        }
                    }
                    // 审批节点操作人不是当前用户的无需显示
                    if (['basicLine', 'productChange', 'productManagerReview', 'teamLeaderAduit', 'requireOnline'].includes(props.stepStatus)) {
                        return !(props.hasAuth || store.getters.userInfo.roles.some((item) => ['产品经理'].includes(item)));
                    } else {
                        return !props.hasAuth;
                    }
                } else {
                    return !store.getters.userInfo.employeeDTO.isPM;
                    // return props.detail.createUserEmpId !== unref(store.getters.userInfo.employeeDTO.empId);
                }
            }
        });
        return {
            checkPrecessRef,
            form,
            disabled
        };
    }
});
</script>